import { checkAuth, fetchCurrentUser, initAuthEvents } from './auth.js';
import { initDashboard } from './dashboard.js';
import { initUsers } from './users.js';
import { initModels } from './models.js';
import { initAgents } from './agent.js';
import { initDocuments } from './documents.js';
import { initSettings } from './settings.js';
import { showSection } from './utils.js';

document.addEventListener('DOMContentLoaded', function() {
    // 检查登录状态
    if (!checkAuth()) return;

    // 初始化各模块
    initAuthEvents();
    initDashboard();
    initUsers();
    initModels();
    initAgents();
    initDocuments();
    initSettings();

    // 获取当前用户信息
    fetchCurrentUser();

    // 默认显示控制面板
    showSection('dashboard');
});